<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script src="html5plus://ready"></script>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="../css/mui.min.css" />
		<link rel="stylesheet" type="text/css" href="../css/dongtai.css"/>
		<script src="../js/flexible.min.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<header class="mui-bar mui-bar-nav">
			<div class="mui-segmented-control">
				<a id="index" >热门动态</a>
				<a id="indext" class="xinggirl">私房照</a>
			</div>
		</header>
		<div id="pullrefresh" class="mui-content">
			<div v-show="videoUrl!=''" class="video-bofang">
				<span id="close" class="mui-icon mui-icon-closeempty"></span>
				<video playsinline webkit-playsinline autoplay style="width: 100%;height: 100%;" :src="videoUrl" ></video>
			</div>
			<div class="item-con" v-for="(item,index) in items" :id="index">
				<div class="item-xinxi" v-on:click="openBlog(item)">
					<div class="img-name">
						<img :src="item.headimg" />
						<span>{{item.nick_name}}</span>
					</div>
				</div>
				<div class="item-shipin" v-if="item.type == 3" v-on:click="playclick(item.surl)">
					<img :src="item.video_cover" />

				</div>
				<div class="item-tupian" v-if="item.type == 1" v-on:click="showdongtai(item)">
					<img :src="item.video_cover" />
				</div>
			</div>
			<div></div>
		</div>
		<div id="showTanChuang"></div>
	</body>

	<script src="../js/mui.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../js/md5.js" type="text/javascript" charset="utf-8"></script>
	<script src="../js/function.js" type="text/javascript" charset="utf-8"></script>
	<script src="../js/vue.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../js/mui.previewimage.js" type="text/javascript" charset="utf-8"></script>
	<script src="../js/mui.zoom.js" type="text/javascript" charset="utf-8"></script>
	<!--<script src="../js/vue-lazyload.js" type="text/javascript" charset="utf-8"></script>-->
	<script type="text/javascript">
		mui.init({
			keyEventBind: {
				backbutton: false,  //Boolean(默认true)关闭back按键监听
				menubutton: false   //Boolean(默认true)关闭menu按键监听
			},
			pullRefresh: {
				container: '#pullrefresh',
				down: {
					style:'circle',//必选，下拉刷新样式，目前支持原生5+ ‘circle’ 样式
				    color:'#fd698d', //可选，默认“#2BD009” 下拉刷新控件颜色
				    height:'50px',//可选,默认50px.下拉刷新控件的高度,
				    range:'100px', //可选 默认100px,控件可下拉拖拽的范围
				    offset:'45px', //可选 默认0px,下拉刷新控件的起始位置
				    auto: false,
					callback: pulldownRefresh
				},
				up: {
					auto:true,
					contentrefresh: '加载更多…',
					callback: jiazai
				}
			}
		});
		mui.previewImage();
		
		var dt = new Vue({
			el:'.mui-content',
			data:{
				items:[],
				videoUrl:''
			},
			methods:{
				playclick:function(vurl){
					this.videoUrl = vurl
				},
				closePlay:function(){
					this.videoUrl = ''
				},
				openBlog: function(vle) {
					openPersonalBlog(vle['uid'], vle['headimg'], vle['nick_name']);
				},
				showdongtai:function(item){
					mui.openWindow({
						url:'page/dongtaishow.html',
						id:'dongtaishow.html',
						extras:{
							uid:item.uid,
							headimg:item.headimg,
							surl:item.surl,
							nick_name:item.nick_name
						},
						styles: {                             // 窗口参数 参考5+规范中的WebviewStyle,也就是说WebviewStyle下的参数都可以在此设置
						    titleNView: {                       // 窗口的标题栏控件
						    	autoBackButton:true,
							    titleText:item.nick_name,                // 标题栏文字,当不设置此属性时，默认加载当前页面的标题，并自动更新页面的标题
							    titleColor:"#FFFFFF",             // 字体颜色,颜色值格式为"#RRGGBB",默认值为"#000000"
							    titleSize:"18px",                 // 字体大小,默认17px
							    backgroundColor:"#fd698d",        // 控件背景颜色,颜色值格式为"#RRGGBB",默认值为"#F7F7F7"
							    progress:{                        // 标题栏控件的进度条样式
							        color:"#00FF00",                // 进度条颜色,默认值为"#00FF00"  
							        height:"2px"                    // 进度条高度,默认值为"2px"         
							    },
							    splitLine:{                       // 标题栏控件的底部分割线，类似borderBottom
							        color:"#CCCCCC",                // 分割线颜色,默认值为"#CCCCCC"  
							        height:"1px"                    // 分割线高度,默认值为"2px"
							    }
						    }
						}
					})
				}
			},
			updated: function() {
				this.$nextTick(function() {
					mui.previewImage();
				})
			}
		})
		if(!isallpay()) {
			//审核状态
			document.getElementById("indext").style.display = "none";
		}
		var md=document.getElementsByTagName("video")[0];
	    if(md.ended){
	        dt.videoUrl = ''
	    }
	    md.addEventListener("ended",function(){
	    	mui.toast('播放结束')
	        setTimeout(function(){dt.videoUrl = ''},500)
	    })
		mui('.video-bofang').on('tap','#close',function(){
			dt.videoUrl = '';
		})
		var page = 0;
		function pulldownRefresh(){
			page = 0;
			jiazai();
			mui('#pullrefresh').pullRefresh().endPulldown(true);
			mui('#pullrefresh').pullRefresh().refresh(true);
		}
		
		var dongtaiurl = getApiUrl('http://www.jiaoyou0.cn', 'userdata/dongtai');
		function jiazai(){
			mui.ajax(dongtaiurl, {
				type: 'GET',
				dataType: 'json',
				timeout: 3000,
				data:{page:page},
				success: function(data) {
					if(data.code==200){
						if(page==0){
							var lda = [];
						}else{
							var lda = dt.items;
						}
						mui.each(data.data,function(index,item){
							lda.push(item)
						})
						dt.items = lda;
						mui('#pullrefresh').pullRefresh().endPullup();
					}else{
						mui.toast('今日暂无更多动态')
						mui('#pullrefresh').pullRefresh().endPullup(true);
					}
					page = page+1;
				},
				error: function(xhr, type, errorThrown) {
					mui.toast('网络不好，重试下吧！')
				}
			})
			
			
		}
		jiazai()
		var backButtonPress = 0;
		mui.back = function(event) {
			backButtonPress += 1;
			if(backButtonPress > 1) {
				plus.runtime.quit()
			} else {
				plus.nativeUI.toast('再按一次退出应用')
			}
			setTimeout(function() {
				backButtonPress = 0
			}, 1000);
			return false
		}
		
		mui('.mui-bar').on('tap','.xinggirl',function(){
			if(!isvipcoin(false)){
				showTanChuang('成为VIP，才可查看神秘的私房！','升级VIP','我不好奇',2,'page/wallet.html')
			}else{
				mui.openWindow({
					url: 'page/sifang.html',
					id: 'sifang',
					createNew: false,
					show:{
						aniShow:'none'
					},
				})
			}
			
		})
	</script>
</html>
